package com.dragon.mmochat.model.scheduleJob;

import java.awt.Color;
import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;

import com.dragon.mmochat.service.MmochatChatService;
import com.dragon.mmochat.util.MmochatUtil;

public class CommonSystemMsgJob implements Job {
	@SuppressWarnings("deprecation")
	@Override
	public void execute(JobExecutionContext arg0) {
		try {
			// 每个小时的0/10/20/30/40/50分触发
			Date now = new Date();
			int day = now.getDay();// 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 =
			// Wednesday, 4 = Thursday, 5 = Friday, 6 =
			// Saturday
			int hour = now.getHours();// 0-23
			int min = now.getMinutes();// 0-59
			if (day == 6 && hour == 21 && min == 0) {
				// 周六21:00触发
				String msg = MmochatUtil.wrapColor("押送镖银活动", Color.red)
						+ "开始啦!大家到余杭(628,246)找"
						+ MmochatUtil.wrapColor("衙役", Color.yellow)
						+ "参加活动吧，据说赏金很丰厚噢!";
				MmochatChatService.sendSystemMsg(msg);
			}
			if (day == 6 && hour == 22 && min == 0) {
				// 周六22:00触发
				String msg = MmochatUtil.wrapColor("押送镖银活动", Color.red)
						+ "结束啦!已经领取了任务的英雄，可以继续完成本次任务噢!";
				MmochatChatService.sendSystemMsg(msg);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
